# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=czmq
pkgver=4.2.0
pkgrel=2
pkgdesc="High-level C binding for ZeroMQ"
url="http://czmq.zeromq.org/"
arch="all !s390x"  # zproxy test timeouts on s390x
license="MPL-2.0"
makedepends="util-linux-dev zeromq-dev cmake"
subpackages="$pkgname-static $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/zeromq/czmq/archive/v$pkgver.tar.gz"

case "$CARCH" in
# crypto tests assume MIPS is little-endian
	mips*)	options="!check";;
esac

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		$CMAKE_CROSSOPTS .
	make -C build
}

check() {
	make -C build test
}

package() {
	make -C build DESTDIR="$pkgdir" install

	mkdir -p "$pkgdir"/usr/lib
	mv "$pkgdir"/usr/share/cmake "$pkgdir"/usr/lib
}

sha512sums="d6b6356c07095579e6780386e6c5ead6f87c1f3a80d15afbfaea24a9c108ef13ab750e7dcffbcc4d8528fb5b14b0b28f08008d513b2cf85f2df10b7cf5903212  czmq-4.2.0.tar.gz"
